{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import java.util.Date;\n",
    "import java.text.SimpleDateFormat;\n",
    "\n",
    "public class BeakerTest {\n",
    "  private Date _date;\n",
    "  private SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mmZ\");\n",
    "  \n",
    "  public BeakerTest() {\n",
    "    _date = new Date();\n",
    "  }\n",
    "\n",
    "  public String getDateTxt() {\n",
    "    return \"Today:\" + sdf.format(_date);\n",
    "  }\n",
    "\n",
    "  public String getDateUpperCaseTxt() {\n",
    "    return getDateTxt().toUpperCase();\n",
    "  }\n",
    "}\n",
    "BeakerTest.class.getSimpleName()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "BeakerTest bt = new BeakerTest();\n",
    "bt.getDateTxt();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import java.util.List;\n",
    "import java.util.ArrayList;\n",
    "import com.twosigma.beakerx.chart.xychart.Plot;\n",
    "import com.twosigma.beakerx.chart.xychart.plotitem.*;\n",
    "import com.twosigma.beakerx.chart.Color;\n",
    "\n",
    "Plot p = new Plot();\n",
    "\n",
    "p.setTitle(\"this is a Java plot\");\n",
    "\n",
    "Bars b = new Bars();\n",
    "\n",
    "List<Number> yList = new ArrayList<Number>();\n",
    "yList.add(2);\n",
    "yList.add(5);\n",
    "yList.add(4);\n",
    "yList.add(8);\n",
    "\n",
    "b.setY(yList);\n",
    "b.setColor(Color.blue);\n",
    "b.setWidth(0.5);\n",
    "\n",
    "p.add(b);\n",
    "  \n",
    "p;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "interface DateGetter {\n",
    "   public String getDateTxt();\n",
    "}\n",
    "DateGetter.class.getSimpleName()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "public class DG2 extends BeakerTest implements DateGetter {\n",
    "}\n",
    "DG2.class.getSimpleName()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%classpath add jar ../../../doc/resources/jar/BeakerXClasspathTest.jar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "System.out.println(\"The Groovy working folder is :\");\n",
    "System.out.println(java.nio.file.Paths.get(\".\").toAbsolutePath().normalize().toString());\n",
    "System.out.println(\"BeakerXClasspathTest.jar exists in this folder\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import com.beaker.BeakerXClasspathTest;\n",
    "\n",
    "BeakerXClasspathTest t = new BeakerXClasspathTest();\n",
    "System.out.println(com.beaker.BeakerXClasspathTest.staticTest);\n",
    "System.out.println(t.getObjectTest());"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%python\n",
    "from beakerx import *\n",
    "pp = Plot(title=\"Title\", xLabel=\"Horizontal\", yLabel=\"Vertical\")\n",
    "pp.add(Line(displayName=\"Line\", x=[1, 4, 6, 8, 10],y=[3, 6, 4, 5, 9]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "press 'Tab' for autocomplete"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "press 'Shift' + 'Tab' for doc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Output usage"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import com.twosigma.beakerx.widget.Output;\n",
    "Output out2 = new Output();\n",
    "OutputManager.setOutput(out2);\n",
    "out2;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import static java.lang.System.out;\n",
    "\n",
    "Thread t = new Thread(() -> {\n",
    "    out.println(\"Some output init\");\n",
    "    try {\n",
    "        Thread.sleep(2000);\n",
    "    } catch (InterruptedException e) {\n",
    "    }\n",
    "    for (int i = 0; i <10 ; i++){\n",
    "        out.println(\"Some output \"+ i);    \n",
    "    }\n",
    "});\n",
    "out.println(\"Start\");\n",
    "t.start();\n",
    "//t.join();\n",
    "out.println(\"end\");\n",
    "\"Thread example result\";"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "OutputManager.clearOutput();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import static java.lang.System.out;\n",
    "for (int i = 0; i <30 ; i++){\n",
    "    out.println(\"Done \"+ i);    \n",
    "}\n",
    "return 3+5;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "OutputManager.setOutput(null);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Java11",
   "language": "java",
   "name": "java"
  },
  "language_info": {
   "codemirror_mode": "text/x-java",
   "file_extension": ".java",
   "mimetype": "",
   "name": "Java",
   "nbconverter_exporter": "",
   "version": "11.0.1"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": false,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": false,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
